package com.kim.nidoya.utils;

import com.kim.nidoya.activity.BaseGroupActivity;
import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;

@SuppressWarnings("deprecation")
public class ActivityDispatchUtil {
	
	/**
	 * 在activitygroup中打开新界面
	 */
	public static void openNewActivity(Context theActivityFrom, Class<?> theClassToOpen, ActivityGroup group, String activityID) {
		//要跳转的Activity  
        Intent intent = new Intent(theActivityFrom, theClassToOpen);  
        // 把Activity转换成一个Window，然后转换成View  
        Window w = group.getLocalActivityManager()  
                .startActivity( activityID, intent);  
        View view = w.getDecorView();  
        //设置要跳转的Activity显示为本ActivityGroup的内容  
        ((BaseGroupActivity) group).replaceView(view);
	}
	
	/**
	 * 返回activitygroup中上一个界面
	 */
	public static void backToAboveActivity(ActivityGroup group) {
		((BaseGroupActivity) group).back();
	}
}
